import java.util.Arrays;

public class Test {
    public static void func(int[] array1,int[] array2,int a,int b) {
        int i = a-1;
        int j = b-1;
        int k = a + b - 1;
        while(i >= 0 && j >= 0) {
            if(array1[i] > array2[j]) {
                array1[k] = array1[i];
                i --;
                k --;
            }else {
                array1[k] = array2[j];
                j --;
                k --;
            }
        }

        while(j >= 0) {
            array1[k] = array2[j];
            j --;
            k --;
        }
    }

    public static void main(String[] args) {
        int[] arr1 = {1,2,3,0,0,0};
        int[] arr2 = {4,5,6};
        func(arr1,arr2,3,3);
        System.out.println(Arrays.toString(arr1));
    }
}
